-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: routerized links #4628
base: canary
Are you sure you want to change the base?
fix: routerized links #4628
Conversation
|
@jprosevear is attempting to deploy a commit to the HeroUI Inc Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe pull request addresses a bug in the link component's handling of the Changes
Assessment against linked issues
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
@@ -110,6 +112,8 @@ export function useLink(originalProps: UseLinkProps) { | |||
"data-focus": dataAttr(isFocused), | |||
"data-disabled": dataAttr(originalProps.isDisabled), | |||
"data-focus-visible": dataAttr(isFocusVisible), | |||
// The `href` prop may be routerized by useAriaLink, so we may merge over top of it | |||
href, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sure that the href on the is set properly
) { | ||
e.preventDefault(); | ||
router.open(e.currentTarget, e, props.href, props.routerOptions); | ||
router.open(e.currentTarget, e, routerLinkProps.href, props.routerOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sure that we use the useHref'ed href for the navigation
may revisit this PR again after #4611 |
Is the hope that the upgrade will fix this or something else? |
@jprosevear RA recently bumped their version and we are still using the second last latest version. The version diff would cause some routing issues. So I wanna double check again after syncing the versions. |
Ok, but based on my patch and investigation the issue is that RA was returning the right info already, it just wasn't being used correctly in Hero. |
eff03db
to
9f13a25
Compare
Rebased. |
@jprosevear do you have a simple sandbox that can reproduce the issue? I need it to test the before & after. |
I do not, unless there is a good starting point for heroui / RR (or Tanstack Router, as per Discord I think it has the same problem) its probably a couple hours of work at least is my guess which is possible but painful obviously. What is the right thing to do from a testing infrastructure standpoint long term? |
Closes #4624
📝 Description
Use the routerized href if available for both the onClick event and the href prop on the element
⛳️ Current behavior (updates)
Currently the original href is used (ignoring the application of useHref) on the onClick and so navigate() for react-router acts on the wrong href and fails for relative links. So if you are at /blogs already and you put href="14" it will try to go to /14 instead of /blogs/14 and the href is decorate with href="14"
🚀 New behavior
navigate() for react-router works, going to /blogs/14 and the element is decorated correctly (/blogs/14) .
💣 Is this a breaking change (Yes/No):
Possible, but I don't think it worked before with relative links in RR; absolute links should still work.
📝 Additional Information
Summary by CodeRabbit
Improvements
href
handling.autoFocus
,isExternal
, andshowAnchorIcon
properties.Accessibility